package com.liuchuanzheng.lcz_study_demo.behavior

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.liuchuanzheng.lcz_study_demo.MainActivity
import com.liuchuanzheng.lcz_study_demo.R
import com.liuchuanzheng.lcz_study_demo.databinding.ActivityBehavior2Binding
import com.liuchuanzheng.lcz_study_demo.databinding.ActivityBehaviorBinding

class Behavior2Activity : AppCompatActivity() {
    lateinit var mViewBinding: ActivityBehavior2Binding
    val adapter: MyAdapter by lazy { MyAdapter(null) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mViewBinding = ActivityBehavior2Binding.inflate(layoutInflater)
        setContentView(mViewBinding.root)
        mViewBinding.recyclerView.setLayoutManager(LinearLayoutManager(this))
        mViewBinding.recyclerView.adapter = adapter
        val mutableList:MutableList<String> = mutableListOf()
        for (i in 0 until 50){
            mutableList.add("${i}")
        }
        adapter.setNewInstance(mutableList)
    }
    inner class MyAdapter(data: MutableList<String>?): BaseQuickAdapter<String, BaseViewHolder>(
        R.layout.rv_item,data) {
        /**
         * Implement this method and use the helper to adapt the view to the given item.
         *
         * 实现此方法，并使用 helper 完成 item 视图的操作
         *
         * @param helper A fully initialized helper.
         * @param item   The item that needs to be displayed.
         */
        override fun convert(holder: BaseViewHolder, item: String) {
            holder.setText(R.id.tv_name,item)
        }

    }
}